package com.sen.ssp.common.session;

import java.util.Map;

/**
 * session信息提取器。主要用于从struts提供的session中提取。
 * 
 * @author sen
 */
public final class SessionFetcher {

	/**
	 * 登陆用户名
	 */
	public static final String USER_NAME = "user_name";
	
	/**
	 * struts2里的session变量.
	 */
	private final Map<String, Object> session;

	private SessionFetcher(final Map<String, Object> session) {
		this.session = session;
	}

	public static SessionFetcher from(final Map<String, Object> session) {
		return new SessionFetcher(session);
	}

	public String getUserName() {
		return (String) session.get(USER_NAME);
	}

	public void setUserLogined(String userName) {
		session.put(USER_NAME, userName);
	}
	
}
